package com.homwee.listMenu.util.view;

import android.content.Context;


import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.homwee.factory.R;
import com.homwee.listMenu.util.MenuItemView;


public class ItemHaveSub extends MenuItemView{
	RelativeLayout mImage;
	TextView mName;
	TextView mValue;
	RelativeLayout layout;
	public ItemHaveSub(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}
	public ItemHaveSub(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}
	public ItemHaveSub(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void initData() {
		// TODO Auto-generated method stub
		layout =(RelativeLayout) LayoutInflater.from(mContext).inflate(R.layout.menu_havesub, null);
		this.addView(layout);
		mImage =(RelativeLayout) layout.findViewById(R.id.ItemImage);
		mName =(TextView) layout.findViewById(R.id.ItemName);
		mValue =(TextView) layout.findViewById(R.id.Value);
		mImage.setBackgroundResource(mMenuData.mNameImage);
		mName.setText(mMenuData.mName);
//		mMenuData.setOnValueChange(new MenuItemData.onValueChange() {
//			
//			public void valueChange(int value) {
//				// TODO Auto-generated method stub
//				if(mMenuData.mOptionValue !=null){
//					mValue.setText(mMenuData.mOptionValue[0]);
//				}
//				Log.v("tv","OptionView valueChange");
//			}
//		});
//		if(mMenuData.mOptionValue !=null){
//			mValue.setText(mMenuData.mOptionValue[0]);
//			mValue.setVisibility(View.VISIBLE);
//		}
	}
	@Override
	public void update() {
		// TODO Auto-generated method stub
		if(mMenuData.isEnable){
			mName.setTextColor(Color.WHITE);
			mValue.setTextColor(Color.WHITE);
		}else{
			mName.setTextColor(Color.GRAY);
			mValue.setTextColor(Color.GRAY);
		}
		if(mMenuData.mOptionStr !=null){
			mValue.setText(mMenuData.mOptionStr);
			mValue.setVisibility(View.VISIBLE);
		}
	}
}